<include file="Public/min-header" /> <!--引入 js css img 文件-->
<link href="__PUBLIC__/css/page.css" rel="stylesheet" type="text/css"> <!--引入分页css 文件-->
</head>
<body>
    <!--导航  start //-->
<include file="Public/header" />
<!--------头部结束-------------->
<div id="main">
    <!--右边菜单-->
    <include file="Bank/menu"/>
    <!--右边菜单End-->
    <div class="mainfr-box">
        <div class="place">
            <span>当前位置：</span>
            <ul class="placeul">
                <li><a href="#">首页 ></a></li>
                <li><a href="#">财务管理 ></a></li>
                <li><a href="#">申请库存</a></li>
            </ul>
            <ul class="placeula">
                <li><a href="javascript:location.reload()"><span class="placea"></span>刷新</a></li>
                <li><a href="javascript:history.go(-1)"><span class="placea"></span>返回上一页</a></li>
            </ul>
        </div>
        <div class="clr"></div>
        <div class="main">
            <form action="" method="post" enctype="multipart/form-data" name="distribut_form" id="distribut_form">
                
                <table width="100%" border="0" class="Register-table">
                    <tr class="odd">
                        <th scope="row" width="130">电子积分余额:</th>
                        <td>{$user.zuce_money}</td>
                       
                    </tr>
                    <tr class="odd">
                        <th scope="row" width="130">库存积分余额:</th>
                        <td>{$user.user_money}</td>
                       
                    </tr>
                    <tr class="odd">
                        <th>产品:</th>
                        <td><span style="color:#fff">保食洁一套：1680元 &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp活水仪一台：8580元</span> </td>
                        
                    </tr>
                    <tr class="odd">
                        <th>净易生组合产品:</th>
                        <td>3860元</td>
                    </tr>
                    <tr class="odd">
                        <th>数量：</th>
                        <td><select name="order_num" onChange="chongzhi()" id="order_num">
                  <option value="4">4</option>
                  <option value="8">8</option>
                  <option value="12">12</option>
                  <option value="16">16</option> 
                  <option value="20">20</option>
                  <option value="24">24</option>
                  <option value="28">28</option>
                  <option value="32">32</option>
                  <option value="36">36</option>
                  <option value="40">40</option>
                  </select></td>
                    </tr>
                    <tr class="odd">
                        <th>总金额:</th>
                        <td><input id="total_amount" name="total_amount" type="text" class="scinput" value="15440" style="width:350px;" readonly></td>
                    </tr>
                    
                    <tr class="odd">
                        <th>付款方式:</th>
                        <td><select name="pay_name"  id="pay_name"> 
                         <option value="汇款">汇款</option>
                        <if condition="$user['zuce_money'] gt 0"> 
                        <option value="电子积分+汇款">电子积分+汇款</option>
                        <option value="电子积分">电子积分</option>
                        </if>
                  </select></td>
                    </tr>
                    <tr class="odd" id="use_zuce_money_pay" style="display: none;">
                        <th>使用电子积分:</th>
                        <td colspan="3"><input id="zuce_money" name="zuce_money" type="text" class="scinput" style="width:350px;"> <span>汇款金额：<i id="finale_amount" style="color: #fff"></i></span></td>
                    </tr>
                    <tr class="odd">
                        <th>收货人姓名:</th>
                        <td colspan="3"><input id="consignee" name="consignee" type="text" class="scinput" style="width:350px;"></td>
                    </tr>
                    <tr class="odd">
                        <th>收货地址:</th>
                        <td colspan="3"><input id="address" name="address" type="text" class="scinput" style="width:350px;"></td>
                    </tr>
                    <tr class="odd">
                        <th>收货人电话:</th>
                        <td colspan="3"><input id="mobile" name="mobile" type="text" class="scinput" style="width:350px;"></td>
                    </tr>
                    <tr class="odd">
                        <th>邮编：</th>
                        <td colspan="3"><input id="zipcode" name="zipcode" type="text" class="scinput" style="width:350px;"></td>
                    </tr>
                    <tr class="odd">
                        <th>备注:</th>
                        <td colspan="3"><input id="user_note" name="user_note" type="text" class="scinput" style="width:350px;"></td>
                    </tr>
                    
                </table>
                <div class="button-box"> 
                    <input type="button" onClick="checkSubmit();" value="提交" class="button-style" id="btn_midefy"></div>
            </form>
            <div class="clr"></div>
           
            <div class="pages"><div align="right">{$show}</div></div>
        </div>
    </div>
    <!--foot-->
    <!--foot-->
    <div class="clr"></div>
    <!--footer start //-->
    <include file="Public/footer"  /> 
             <!--footer  end //-->
             </body>
        </html>
        <script>
        var user_zuce_money= Number("{$user.zuce_money}");
        // 表单验证提交
            function checkSubmit() {
                var consignee = $.trim($('#consignee').val());
                var address = $.trim($('#address').val());
                var mobile = $.trim($('#mobile').val());
                var zipcode = $.trim($('#zipcode').val());
                var zuce_money = $.trim($('#zuce_money').val());
                
                if (consignee == '')
                {
                alert('收货人姓名必填');
                        return false;
                }
                 if (address == '')
                {
                    alert('收货人地址必填');
                    return false;
                }

                if (mobile == '')
                {
                    alert('收货人电话必填');
                    return false;
                }

                if (zuce_money != '' &&zuce_money>user_zuce_money )
                {
                    alert('电子积分超额');
                    return false;
                }
                if (zipcode == '')
                {
                    alert('邮编必填');
                    return false;
                }
               
                $('#distribut_form').submit();
            }

            function chongzhi() {
               var order_num =$('#order_num').val();
               var total_amount=order_num*3860;
               $('#total_amount').val(total_amount);
            }

            $("#pay_name").change(function(){
                if ($(this).val()=='电子积分+汇款') {
                    $("#use_zuce_money_pay").show(); 
                }else{
                     $("#use_zuce_money_pay").hide(); 
                }
            }); 



            $('#zuce_money').blur(function () {
              
                var input_zuce_money=Number($(this).val());
               var total_amount = $('#total_amount').val();
                if (input_zuce_money != '' )
                {   
                  if (input_zuce_money >user_zuce_money) {
                    alert('电子积分超额');
                    $(this).focus();
                    return false;
                    }else{

                        $('#finale_amount').text(total_amount-input_zuce_money)

                    }
                }

            });

        </script>	